home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / object.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-30  |  1.1 KB  |  50 lines

  1. #include "object.h"
  2.  
  3. std::vector<MESH*> objectMeshes;
  4.  
  5. HRESULT LoadObjectResources(IDirect3DDevice9* Device)
  6. {
  7.     MESH *tree = new MESH("meshes/tree.x", Device);
  8.     objectMeshes.push_back(tree);
  9.  
  10.     MESH *stone = new MESH("meshes/stone.x", Device);
  11.     objectMeshes.push_back(stone);
  12.  
  13.     return S_OK;
  14. }
  15.  
  16. void UnloadObjectResources()
  17. {
  18.     for(int i=0;i<objectMeshes.size();i++)
  19.         objectMeshes[i]->Release();
  20.  
  21.     objectMeshes.clear();
  22. }
  23.  
  24. //////////////////////////////////////////////////////////////////////////////
  25. //                            OBJECT CLASS                                    //
  26. //////////////////////////////////////////////////////////////////////////////
  27.  
  28. OBJECT::OBJECT()
  29. {
  30.     m_type = 0;
  31. }
  32.  
  33. OBJECT::OBJECT(int t, INTPOINT mp, D3DXVECTOR3 pos, D3DXVECTOR3 rot, D3DXVECTOR3 sca)
  34. {
  35.     m_type = t;
  36.     m_mappos = mp;
  37.     m_meshInstance.SetPosition(pos);
  38.     m_meshInstance.SetRotation(rot);
  39.     m_meshInstance.SetScale(sca);
  40.     m_meshInstance.SetMesh(objectMeshes[m_type]);
  41.     m_visible = false;
  42.  
  43.     m_BBox = m_meshInstance.GetBoundingBox();
  44. }
  45.  
  46. void OBJECT::Render()
  47. {
  48.     m_meshInstance.Render();
  49. }
  50.